'''
    字典 {key:value,key:value...}
    长度：键值对的个数
        key 一般是字符串类型 key不能重复
        value可以是任意类型 基本数据类型 高级类型
    字典没有下标

    字典的操作：
        增：添加键值对
'''

user = {"username":"admin","password":"admin123"}

student= {

    "name":"小李",
    "age":20,
    "sex":"男",
    "score":22,
    "isHealthy":True,
    "hoby":["足球","篮球"],
    "tercher":{"name":"王老师","age":40}

}

user["status"]="启用"
print(user)

user["password"]="123456"
print(user)
#删除
# del user["status"]
# print(user)
#
# user.pop("username")
# print(user)
#
# user.clear()
# print(user)

#通过key获取value
print(user["password"])
print(user.get("123"))
print(user.get("password"))

#获取所有的key构成的列表
keys = student.keys()
print(keys)
# 获取所有的值构成的列表
values = student.values()
print(values)
# 获取所有键值构成的列表
items = student.items()
print(items)

print(len(student))

for k in keys:
    print(k)
    print(student[k])

for v in values:
    print(v)

for k,v in items:
    print(k)
    print(v)

str1 = "HelloWorld"
result = {}
for s in str1:
    result[s]= str1.count(s)
print(result)







